// $_FILEHEADER_BEGIN ***************************
// 版权声明:Timer
// Copyright © 2015 - Timer All Rights Reserved
// 文件名称: LineView.m
// 创建日期: 15/12/6
// 创 建 人: 甄鑫
// 文件说明: 0.5像素线
// $_FILEHEADER_END ******************************


#import "LineView.h"

#define kLinePx (0.5)

@implementation LineView
{
    UIView * _realLineView;
}

-(void)awakeFromNib
{
    [self createUI];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

- (void)createUI
{
    CGRect lineRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    
    __block UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
    
    switch (self.type)
    {
        case LINE_TYPE_TOP:
        {
            edge.bottom = kLinePx;
        }break;
        case LINE_TYPE_BOTTOM:
        {
            edge.top = kLinePx;
        }break;
        case LINE_TYPE_LEFT:
        {
            edge.right = kLinePx;
        }break;
        case LINE_TYPE_RIGHT:
        {
            edge.left = kLinePx;
        }break;
        default:
            break;
    }
    _realLineView = [[UIView alloc]initWithFrame:lineRect];
    [_realLineView setBackgroundColor:self.backgroundColor];
    [self addSubview:_realLineView];
    
    [_realLineView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.edges.equalTo(self).with.insets(edge);
     }];
    [self setBackgroundColor:[UIColor clearColor]];
}
@end
